<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
                <el-form-item label="文章标题">
                    <el-input
                            class="w-[150px]"
                            v-model="queryParams.name"
                            placeholder="请输入文章标题"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none mt-4" shadow="never">
            <el-tabs class="demo-tabs" v-model="type" @tab-click="handleTabclick">
                <el-table size="large" v-loading="pager.loading" :data="pager.lists" style="width: 100%">
<!--                    <el-table-column label="排序权重" prop="name" min-width="180">-->
<!--                        <template #default="{ row }">-->
<!--                            <el-input-number v-model="row.phone" :min="1" :max="10" @change="handleChange" />-->
<!--                        </template>-->
<!--                    </el-table-column>-->
                    <el-table-column label="ID" prop="name"  min-width="50">
                        <template #default="{ row }">
                            {{ row.id }}
                        </template>
                    </el-table-column>
                    <el-table-column label="问题名称" prop="name"  min-width="100">
                        <template #default="{ row }">
                            {{ row.name }}
                        </template>
                    </el-table-column>
                    <el-table-column label="投诉凭证" prop="name"  min-width="100">
                        <template #default="{ row }">
                            <image-contain
                                v-if="row.cover"
                                :src="row.cover"
                                :width="45"
                                :height="45"
                                :preview-src-list="[row.cover]"
                                preview-teleported
                                fit="contain"
                            />
                        </template>
                    </el-table-column>
                    <el-table-column label="问题内容" prop="name"  min-width="150">
                        <template #default="{ row }">
                            <span v-html="row.content"></span>
                        </template>
                    </el-table-column>
                    <el-table-column label="ID" prop="阅读人数"  min-width="50">
                        <template #default="{ row }">
                            {{ row.num_read }}
                        </template>
                    </el-table-column>
                    <el-table-column label="投诉状态" prop="name"  min-width="50">
                        <template #default="{ row }">
                            <el-tag class="ml-2" :type="['success', 'error'][row.status-1]"> {{['正常', '隐藏'][row.status-1] }}</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column label="创建时间" prop="创建时间"  min-width="100">
                        <template #default="{ row }">
                            {{ row.create_at }}
                        </template>
                    </el-table-column>
                </el-table>
                <div class="flex justify-end mt-4">
                    <pagination v-model="pager" @change="getLists" />
                </div>
            </el-tabs>
        </el-card>
    </div>
</template>
<script lang="ts" setup>
    import { getFaqList } from '@/api/afterSale'
    import { usePaging } from '@/hooks/usePaging'
    import feedback from "@/utils/feedback";
    import router, { getRoutePath } from '@/router'

    const queryParams = reactive({
        name: '',
    });

    const { pager, getLists, resetPage, resetParams } = usePaging({
        fetchFun: getFaqList,
        params: queryParams
    });

    getLists();

    const handleChange = async (id: number) => {
        // await feedback.confirm('确定处理完成？');
        // complainHandle({uuid: id});
        // getLists()
    };

</script>
